package com.ideal.blockchain.dto.request;

import com.google.protobuf.InvalidProtocolBufferException;
import org.hyperledger.fabric.protos.common.Common;
import org.hyperledger.fabric.sdk.BlockInfo;

import static com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type.String;

public class BlockInfoDto {
    public String dataHash;
    public String channelId;
//    public Common.Block block;
    public String previousHash;
    public long blockNumber;
    public int envelopeCount;
    public boolean isFiletered;
    public String transActionsMetaData;
    public BlockInfoDto(BlockInfo blockInfo){
        this.dataHash = new String (blockInfo.getDataHash());
        try {
            this.channelId = blockInfo.getChannelId();
        } catch (InvalidProtocolBufferException e) {
            e.printStackTrace();
        }
//        this.block = blockInfo.getBlock();
        this.previousHash = new String(blockInfo.getPreviousHash());
        this.blockNumber = blockInfo.getBlockNumber();
        this.envelopeCount = blockInfo.getEnvelopeCount();
        this.isFiletered = blockInfo.isFiltered();
        this.transActionsMetaData = new String(blockInfo.getTransActionsMetaData());
    }
}
